package com.yiqi.liebang.feature.mine.view;

import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;

import com.flyco.tablayout.SlidingTabLayout;
import com.suozhang.framework.framework.BaseActivity;
import com.yiqi.liebang.R;

import java.util.ArrayList;

import butterknife.BindView;

public class CouponActivity extends BaseActivity implements Toolbar.OnMenuItemClickListener {


    @BindView(R.id.toolbar)
    Toolbar mToolbar;
    @BindView(R.id.tl_4)
    SlidingTabLayout mTl4;
    @BindView(R.id.vp)
    ViewPager mVp;
    private final String[] mTitles = {"未使用", "已使用", "已过期"};
    private ArrayList<Fragment> mFragments = new ArrayList<>();


    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_coupon;
    }

    @Override
    protected void initInjector() {

    }

    @Override
    protected void initView() {
        mToolbar.inflateMenu(R.menu.menu_coupon);
        initToolBar(mToolbar, "我的优惠券", true, true);
        for (int i = 0; i < mTitles.length; i++) {
            mFragments.add(CouponFragment.getInstance(i));
        }

        mToolbar.setOnMenuItemClickListener(this);
        mTl4.setViewPager(mVp, mTitles, this, mFragments);
    }

    @Override
    protected void initData() {
    }

    @Override
    public boolean onMenuItemClick(MenuItem item) {
        if (item.getItemId()==R.id.action_coupon){
            startActivity(new Intent(this,CouponInstructionsActivity.class));
        }
        return false;
    }
}
